/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2025-02-10 09:45:16
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2025-02-10 11:10:22
 * @FilePath: /2024-4-20-pipe/named_pipe/server.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "named_pipe.hpp"

// server 只读 掌管着整个管道的生命周期 
int main()
{
    named_pipe fifo(com_path,Creator);
    if(fifo.OpenForRead())
    {
        // 只要以读的方式打开成功，就一直读！
        while(true)
        {
            string message;
            int n=fifo.ReadNamedPipe(&message);
            if(n>0)
            {
                cout<<"Client say> "<< message <<endl;
            }
        }

    }
    return 0;
}